﻿using HBase;
using hCommand;
using Net.http;
using Persistence;
using System.Collections.Generic;
using System.Linq;

namespace WebApi {
    [FormAuthenticationFilter]

    [RoutePrefix("Batch")]
    public class BatchController : BaseApiController
    {
        IBatchServer authorityServer = WMSDalFactray.getDal<IBatchServer>();
   
        [HttpPost, Route("FindPage")]
        public BaseResult FindPage([FromBody] BatchDto dto)
        {
            Page<WhBatch> info = authorityServer.QueryBatchPage<WhBatch>(dto);
            return BaseResult.Ok(info);
        }

 
        //导出
        [HttpPost, Route("GetExportList")]
        public BaseResult GetExportList([FromBody] BatchDto dto)
        {
            var info = authorityServer.GetExportList(dto);
            List<SysDict> sysDicts = authorityServer.GetAll<SysDict>().Where(x => x.dType == "units").ToList();

            foreach (var i in info)
            {
                i.unit = sysDicts.Where(x => x.value.ToString() == i.unit).FirstOrDefault().label;
            }
            return BaseResult.Ok(info);
        }
    }
}